package com.bianyuanren.v4.controller.dynamicreport;

import java.util.List;

import com.bianyuanren.v4.service.dynamicreport.IPpDynamicReportService;
import com.bianyuanren.v4.pojo.dynamicreport.PpDynamicReport;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.bianyuanren.common.annotation.Log;
import com.bianyuanren.common.enums.BusinessType;
import com.bianyuanren.common.core.controller.BaseController;
import com.bianyuanren.common.core.domain.AjaxResult;
import com.bianyuanren.common.core.page.TableDataInfo;

/**
 * 举报动态Controller
 * 
 * @author bianyuanren
 * @date 2020-05-14
 */
@Controller
@RequestMapping("/api/dynamicreport")
public class PpDynamicReportController extends BaseController
{
    private String prefix = "system/report";

    @Autowired
    private IPpDynamicReportService ppDynamicReportService;

    @RequiresPermissions("system:report:view")
    @GetMapping()
    public String report()
    {
        return prefix + "/report";
    }

    /**
     * 查询举报动态列表
     * 查询自己的
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(PpDynamicReport ppDynamicReport)
    {
        startPage();
        List<PpDynamicReport> list = ppDynamicReportService.selectPpDynamicReportList(ppDynamicReport);
        return getDataTable(list);
    }

    /**
     * 新增保存举报动态
     */
    @Log(title = "举报动态", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(PpDynamicReport ppDynamicReport)
    {
        return toAjax(ppDynamicReportService.insertPpDynamicReport(ppDynamicReport));
    }

    /**
     * 修改保存举报动态
     */
    @Log(title = "举报动态", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(PpDynamicReport ppDynamicReport)
    {
        return toAjax(ppDynamicReportService.updatePpDynamicReport(ppDynamicReport));
    }

    /**
     * 删除举报动态
     */
    @RequiresPermissions("system:report:remove")
    @Log(title = "举报动态", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(ppDynamicReportService.deletePpDynamicReportByIds(ids));
    }
}
